package com.combetter.changxing.viewmodel;

import android.app.Application;
import android.content.Intent;
import android.support.annotation.NonNull;

import com.combetter.changxing.db.entity.User;
import com.combetter.changxing.net.service.APIService;
import com.combetter.changxing.ui.activity.MainActivity;
import com.combetter.changxing.ui.activity.RegisterActivity;
import com.combetter.changxing.util.AppManager;
import com.combetter.changxing.util.LogUtil;
import com.combetter.changxing.util.ToastUtils;
import com.combetter.changxing.viewmodel.base.BaseViewModel;

import cn.jpush.android.api.JPushInterface;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by 深圳唐龙飞讯科技有限公司 on 2018/6/6.
 */

public class MainViewModel extends BaseViewModel{
    //已配对设备数据
//    public List<FacilityModel> facilityList = new ArrayList<>();

    public MainViewModel(@NonNull Application application) {
        super(application);

//        mHttpRequest.createService(APIService.class)
//                .login(map)
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribeOn(Schedulers.io())
//                .doOnError(throwable -> dialog.dismiss())
//                .subscribe(userHttpResult -> {
//                    dialog.dismiss();
//                    LogUtil.e("登录返回：", userHttpResult);
//                    if (userHttpResult.getCode() == 200) {
//                        User user = userHttpResult.getData();
//                        JPushInterface.setAlias(context, 0, user.getUid());
//                        user.setPhone(user.getPhone());
//                        appDatabase.userDao().insertUser(user);
//                        context.startActivity(new Intent(context, MainActivity.class));
//                        AppManager.finishAllActivity();
//                    } else if (userHttpResult.getCode() == 610) {  //第三方新用户
//                        Intent intent = new Intent(context, RegisterActivity.class);
//                        intent.putExtra("openId", map.get("openId"));
//                        intent.putExtra("nickname", nickname.get());
//                        intent.putExtra("figureurl", figureurl.get());
//                        context.startActivity(intent);
//                    } else {
//                        ToastUtils.error(userHttpResult.getMsg());
//                    }
//                });



    }

}
